1. Field of the Invention
The present invention generally relates to multiple instruction set processors and, more particularly, to techniques for detecting specific events and to techniques for processing the specific events in an event detection mechanism for a multiple instruction-set processor.
2. Discussion of Background
Applications coded in the Java language have increasingly been used in cellular phones and personal digital assistants. Java is an object-oriented programming language similar to C++, developed by Sun Microsystems, Inc. “Java” is a registered trademark of Sun Microsystems, Inc. A factor of acceptance of the Java language is that the Java language has such characteristics that the intermediate language is converted into instructions specific to the central processing unit (CPU) using a virtual machine (VM) for execution. Portability is high because any CPU having a virtual machine allows Java applications to be executed regardless of the kind of the CPU. The intermediate language, which refers to results of compiling for producing Java execution objects, is also referred to as Java bytecodes or simply as bytecodes.
A virtual machine (VM) is typically in the form of software, in other words, a software VM. Since bytecodes are interpreted and executed by an interpreter, processing is generally slow. For this reason, a hardware accelerator is used to execute frequently used bytecodes by hardware and thereby achieve high speed processing. An example of the hardware accelerator is described in “Nikkei Electronics, No. 797, pp. 168-176, 2001. 6. 4 (this article is the translation of “Java to go: Device 1; Microprocessor Report, vol 15, no. 2, Feb. 2001”).
An aspect of Java involves thread switching during processing of bytecodes by a hardware accelerator. The specifications of VM are decided by Sun Microsystems, Inc. Sun Microsystems, Inc. discloses plural specifications as “Java2.” Of these specifications, specifications for built-in equipment are “J2ME.” The specifications further have two specifications, CDC for network information equipment and CLDC for portable network information equipment limited in CPU and memory.
Generally, an OS executing plural normal tasks uses timer interrupts to detect the timing of switching between the tasks. Java also executes plural tasks in parallel. In Java, the above-described tasks are referred to as threads. Thread switching in reference implementation of CDC shown by Sun Microsystems, Inc. is also made by timer interrupts. On the other hand, in reference implementation of CLDC, to implement thread switching more easily, the number of executed bytecodes is counted, and thread switching is made when it reaches a given value.
FIG. 2 shows a conceptual diagram of the thread switching. Three threads, A(TH_A), B(TH_B), and C(TH_C), are executed, and TH_A1 in TH_A is first executed. When the number of bytecodes executed in TH_A1 reaches a given value, VM switches the thread to be executed to TH_B1. When the number of bytecodes executed in TH_B1 reaches a given value, switching is made to TH_C1, and then to TH_A2.
Conventionally, the counter decrementing and underflow checking have been performed by software. For example, a count number is mapped onto a general register of a CPU and a counter is decremented by an instruction specific to the CPU. In this case, an instruction to decrement a count and a conditional branch instruction for task switching are executed for each bytecode. Unfortunately, such a technique would increase the number of execution instructions and high speed operations would become more difficult in comparison with timer interrupts by normal hardware.
VM specifications similar to thread switching include garbage collection. VM has memory areas used at random, and disused areas remain discontinuously in the memory areas as the execution of Java programs proceeds. Accordingly, VM makes memory reorganization called garbage collection. The timing of checking whether to make garbage collection depends on VM. In CDC reference implementation shown by Sun Microsystems, Inc., the number of backward branches is counted, and when the counter underflows, whether to make garbage collection is checked. Also in this case, the counter decrementing and underflow checking were performed by software, and as in the thread switching, the number of execution instructions increases and high speed operations became difficult.
Another specification of Java includes Java exceptions. Java has processing called Java exceptions specific to Java. Each time a program attempts to access data on an array structure, Java checks to see that a pointer to the array is not null, and the index to access is not out of bounds. Java generates null pointer exception if the pointer is null, and array index out of bounds exception if the index is out of bounds, and causes a branch to an exception handling routine. Other Java exceptions include arithmetic exception generated when a division by 0 is attempted. Each time an array is accessed, it is necessary to check that the pointer is not null, and that the index to access is not out of bounds. An attempt to perform such checking by software increases the number of execution instructions, making high speed operations difficult.